package com.easyfile.easyfilemaster.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easyfile.easyfilemaster.entity.FolderDetail;
import com.easyfile.easyfilemaster.entity.FolderInfo;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * @author chenpeman
 * @date 2022年05月06日 15:54
 */
public interface FolderMapper extends BaseMapper<FolderDetail> {
    /**
     * 分页查询文件夹
     *
     * @param page         the page
     * @param queryWrapper the query wrapper
     * @return the child folders
     */
    IPage<FolderInfo> getChildFolders(IPage<?> page,
                                      @Param(Constants.WRAPPER) Wrapper<?> queryWrapper);

    /**
     * 通过父文件夹id和文件夹名判断是否有同名文件夹
     *
     * @param pid  the pid
     * @param name the name
     * @return the list
     */
    List<String> selectName(Long pid,String name);

    /**
     * 通过id更新文件夹的 子文件夹数量、子文件数量、子文件大小
     *
     * @param addFolderNumber the add folder number
     * @param addFileNumber   the add file number
     * @param addFileCapacity the add file capacity
     * @param id              the id
     * @return the int
     */
    int updateFolderAndFileInfoById(Long addFolderNumber, Long addFileNumber, Double addFileCapacity, Long id, Date updateTime);

    /**
     * 获取当前目录下的所有文件夹id
     *
     * @param queryWrapper the query wrapper
     * @return the list
     */
    List<Long> selectFolderIds(@Param(Constants.WRAPPER) Wrapper<?> queryWrapper);
}
